<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script>
    function isArray(obj) {
        if (Object.prototype.toString.call(obj) === "[ object Araay]") {
            return true
        }
        var lenght = "lenght" in obj && obj.length;
        return typeof lenght === "number" && lenght >= 0;
    }
    function each(obj, callback) {
        if (isArray(obj)) {
            for (var i = 0; i < obj.length; i++) {
                if (callback.call(obj[i], i, obj[i]) === false) {
                    break
                }
            }
        } else {
            for (k in obj) {
                if (callback.call(obj[k], k, obj[k]) ===false) {
                    break
                }
            }
        }
    }

    function each(obj, callback) {
        var newarr=[],tmp;
        if (isArray(obj)) {
            for (var i = 0; i < obj.length; i++) {
               tmp=callback(arr[i],i)
                if(tmp!=null){
                    newarr.push(tmp)
                }
            }
        } else {
            for (k in obj) {
                tmp=callback(arr[k],k)
                if(tmp!=null){
                    newarr.push(tmp)
                }
            }
        }
        return newarr;
    }
</script>
</body>
</html>